<div class="layui-card-body">
    <form class="layui-form" action="{:url()}" method="post" style="width: 800px;">
        <div class="layui-form-item">
            <label class="layui-form-label">公司名称</label>
            <div class="layui-input-block">
                <input type="text" name="company" value="{$info.company|default=''}" class="layui-input"
                       autocomplete="off"
                       placeholder="40汉字以内">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="username" value="{$info.username|default=''}" class="layui-input"
                       autocomplete="off"
                       placeholder="20汉字以内">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input type="text" name="mobile" value="{$info.mobile|default=''}" class="layui-input"
                       autocomplete="off"
                       placeholder="中国大陆手机号码">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">用户密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" class="layui-input" autocomplete="off"
                       placeholder="不修改保持为空">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发票收件人</label>
            <div class="layui-input-block">
                <input type="text" name="inname" value="{$info.inname|default=''}" class="layui-input"
                       autocomplete="off"
                       placeholder="收件人姓名">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发票收件地址</label>
            <div class="layui-input-block">
                <input type="text" name="address" value="{$info.address|default=''}" class="layui-input"
                       autocomplete="off"
                       placeholder="收件地址">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发票收件电话</label>
            <div class="layui-input-block">
                <input type="text" name="inmobile" value="{$info.inmobile|default=''}" class="layui-input"
                       autocomplete="off"
                       placeholder="发票收件电话">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户状态</label>
            <div class="layui-input-inline">
                <select name="status" lay-search>
                    <volist name="user_status" id="vo" key="k">
                        <option value="{$k}"
                        <notempty name="info.status">
                            <eq name="$k" value="$info.status">selected="selected"</eq>
                        </notempty>
                        > {$vo} </option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">注册时间</label>
            <div class="layui-input-block">
                <input type="text" value="{$info.create_time|default=''}" class="layui-input"
                       autocomplete="off" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最后登录时间</label>
            <div class="layui-input-block">
                <input type="text" value="{$info.last_login_time|default=''}" class="layui-input"
                       autocomplete="off" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最后登录IP</label>
            <div class="layui-input-block">
                <input type="text" value="{$info.last_login_ip|default=''}" class="layui-input"
                       autocomplete="off" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">系统备注</label>
            <div class="layui-input-block">
                <div id="sys_info">
                    <p>{$info.sys_info|raw|default=""}</p>
                </div>
            </div>
        </div>
        <textarea name="sys_info" id="newinfo" style="display: none">{$info.sys_info|raw|default=""}</textarea>
        <input type="hidden" name="id" value="{$info.id|default=''}">
    </form>
</div>

<script type="text/javascript">
    layui.use(['element', 'form', 'layer', 'formSelects'], function () {
        var form = layui.form
            , formSelects = layui.formSelects
            , $ = layui.$
            , element = layui.element
            , laydate = layui.laydate;

        var E = window.wangEditor
        var editor = new E('#sys_info')
        // 或者 var editor = new E( document.getElementById('editor') )
        editor.customConfig.menus = [
            'head',  // 标题
            'bold',  // 粗体
            'fontSize',  // 字号
            'fontName',  // 字体
            'italic',  // 斜体
            'underline',  // 下划线
            'strikeThrough',  // 删除线
            'foreColor',  // 文字颜色
            'link',  // 插入链接
            'list',  // 列表
            'justify',  // 对齐方式
            'quote',  // 引用
            'image',  // 插入图片
            'table',  // 表格

            'undo',  // 撤销
            'redo'  // 重复
        ]
        editor.customConfig.uploadImgMaxSize = 10 * 1024 * 1024
        editor.customConfig.uploadImgTimeout = 30000
        editor.customConfig.uploadFileName = 'file'
        editor.customConfig.zIndex = 100;
        editor.customConfig.debug = true;
        editor.customConfig.onchange = function (html) {
            $('#newinfo').html(html)
        }
        editor.customConfig.customUploadImg = function (files, insert) {
            var index = layer.load(1, {time: 10 * 1000});
            $.ajax({
                type: "post",
                url: "/qiniu/gettoken",
                async: true,
                success: function (res) {
                    if (res.code == 0) {
                        var token = res.uptoken;
                        var fileName = res.path + files[0].name;
                        var downloadurl = res.downloadurl;
                        var config = {
                            retryCount: 6,
                        };
                        var putExtra = {
                            fname: "",
                            params: {},
                            mimeType: null
                        };
                        var observable = qiniu.upload(files[0], fileName, token, putExtra, config);
                        var subscription = observable.subscribe(
                            {
                                next(res) {
                                    console.log(res)
                                },
                                error(res) {
                                    console.log(res)
                                },
                                complete(res) {
                                    layer.close(index);
                                    insert(downloadurl + '?file=' + res.key)
                                }
                            }
                        );
                    } else {
                        console.log(res.msg)
                    }

                }
            });
        }
        editor.create()

    });

</script>






